import {BASE64_TYPE} from '@/config' // 处理base64
export function hysmDataInit(obj) { // 好友实名
  return obj.qqda.hysm.map((item) => {
    return {
      name: item.xm,
      num: item.num
    }
  })
}

export function yxsmDataInit(obj) { // 邮箱实名
  return obj.qqda.yxsm.map((item) => {
    return {
      name: item.xm,
      num: item.num
    }
  })
}

export function qsmDataInit(obj) { // 群实名
  return obj.qqda.qsm.map((item) => {
    return {
      name: item.xm,
      num: item.num
    }
  })
}

export function znldDataInit(obj) { // 智能落地
  return obj.znld.map((item) => {
    return {
      name: item.xm, // '张三',
      img: item.xp === '' ? '/static/default/head.png' : `${BASE64_TYPE}${item.xp}`,
      num: item.sfzh.substring(14),
      tip: item.bs.map((i) => {
        return {text: i, is: true}
      })
    }
  })
}

export function sjjqajDataInit(obj) {
  return obj.sjjqaj.map((item) => {
    return {
      systemid: item.systemid,
      tableName: item.tableName,
      type: item.type,
      img: item.xp === '' ? '/static/default/head.png' : `${BASE64_TYPE}${item.xp}`,
      number: item.bh, // 'A4347328973873857357',
      name: item.mc,
      label: item.type === '0' ? '警情' : '案件',
      tags: item.type === '0' ? [] : [{text: item.ajlb, is: true}, {text: item.ajzt, is: true}],
      time: item.jjsj || item.fasj,
      address: item.bjnr || item.fadd
    }
  })
}

export function hyDataInit(obj) {
  return obj.hyArr.reduce((resObj, item, index) => {
    let obj = {
      tableName: item.tableName,
      type: item.type,
      systemid: item.systemid,
      name: item.hyxm,
      phone: item.qqh, // '15089012341',
      callNumber: item.tlcs, // '234',
      lastTime: item.zhtlsj, // '2018-3-28 16:06:46',
      realName: item.sm.map((i) => {
        return {name: i.xm, num: i.num}
      }),
      identity: item.zssf.map((i) => {
        return {
          tableName: i.tableName,
          systemid: i.systemid,
          name: i.xm,
          idcard: i.sfzh,
          lab: i.bs
        }
      })
    }
    if (obj.type === '00') {
      resObj['type_0'].push(obj)
    } else if (obj.type === '01') {
      resObj['type_1'].push(obj)
    } else if (obj.type === '02') {
      resObj['type_2'].push(obj)
    } else if (obj.type === '03') {
      resObj['type_3'].push(obj)
    }
    return resObj
    // if (obj.type === '00') {
    //   resObj.push(obj)
    // }
  }, {
    type_0: [],
    type_1: [],
    type_2: [],
    type_3: []
  })
}

export function hyTypeDataInit(obj) {
  return {
    'clt_num': obj.clt_num,
    'tjd_num': obj.tjd_num,
    'jtd_num': obj.jtd_num
  }
}

export function qUniteCreateInit(obj) {
  return obj.create.map((item) => {
    return {
      tableName: item.tableName,
      systemid: item.systemid,
      name: item.mc,
      number: item.bsh,
      remark: item.myname, // '小庞',
      member: item.num, // '12',
      speak: item.fycs, // '250',
      lastTime: item.zhfysj, // '2018-3-30 14:49:14',
      caseType: item.cysalx
    }
  })
}

export function qUniteJoinInit(obj) {
  return obj.join.map((item) => {
    return {
      tableName: item.tableName,
      systemid: item.systemid,
      name: item.mc,
      number: item.bsh,
      remark: item.myname, // '小庞',
      member: item.num, // '12',
      speak: item.fycs, // '250',
      lastTime: item.zhfysj, // '2018-3-30 14:49:14',
      caseType: item.cysalx
    }
  })
}

export function hytlDataInit(obj) {
  return obj.hytl.map((item) => {
    return {
      tableName: item.tableName,
      systemid: item.systemid,
      mobile: item.qqh, // '17620132214',
      name: item.xm, // '张文英',
      time: item.lastTime, // ' 2017-3-13 12:20:09',
      count: item.num // '212'
    }
  })
}

export function qqtlDataInit(obj) {
  return obj.qqtl.map((item) => {
    return {
      tableName: item.tableName,
      systemid: item.systemid,
      mobile: item.qh, // '17620132214',
      name: item.mc, // '张文英',
      time: item.lastTime, // ' 2017-3-13 12:20:09',
      count: item.num, // '212',
      detail: item.detail
    }
  })
}
